﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Vmago.Models
{
    public class RepositoryCategory:ICategory 
    {
         private CategoryDataContext  dataContext;

         public RepositoryCategory()
        {
            dataContext = new CategoryDataContext();
        }

        #region ICategory Members  
        
        public IEnumerable<Class> getClass()
        {
            IEnumerable<Class> c = from p in dataContext.Classes
                                   select p;
            return c;
        }

        IEnumerable<Category> ICategory.getCategory(int ClassID)
        {
            IEnumerable<Category> c = from p in dataContext.Categories
                                      where p.classID.Equals(ClassID)
                                      select p;
            return c;

        }

        public IEnumerable<Category> getSubCategory(int ParentCategoryID)
        {
            IEnumerable<Category> c = from p in dataContext.Categories 
                                      where p.CategoryXrefs.Equals(ParentCategoryID)
                                      select p;
            return c;

        }

        public IEnumerable<SubCategory> getSubCategoryCityMaster(int ClassID) 
        {
            IEnumerable<SubCategory> c = from p in dataContext.SubCategories
                                         where p.classID.Equals(ClassID)
                                         select p;
            return c;
        }
        #endregion
    }
}
